function greeter(person: Array<string>) {
    return "Hello, " + person;
}

function enumType(em: Color) {
    return '类型:颜色枚举 - ' + (em === Color.Red ? '红色' : '其他颜色');
}

let user = ['1', '2', '3'];

enum Color {
    Green,
    Red,
    Bule,
    Yellow
}

let red: Color = Color.Red;

// document.body.innerHTML = greeter(user);
document.getElementById("app").innerHTML = enumType(red);

function error(message: string): never {
    throw new Error(message)
}

// document.getElementById("error").innerHTML = error("别想了");
let value: any = '类型';
let str = <string>value;
console.log('value的值', str);

let len = (str as string).length;
console.log('value的长度', len)

function getAge(age: number = 0): number {
    return age + 1;
}

getAge(2);

function fn(x:number,y:number):number ;
function fn(x:string,y:string):string ;


function fn(x: any, y: any):any {
    return x + y;
}
fn(1,2)

// let document :any;
//会自动推到事件函数里的this
// document.onclick = function () {
//     //
//     // this.a
// }
let obj1 ={
    a:1,
    //在ts中函数的第一个参数this是用来约束类型
    // 假参数,运行过程不存在
    fn(this:Document){
        this.querySelector('app');
    }
}

